﻿namespace BigfootMVC.Helpers
{
    /// <summary>
    /// This is a list item used when creating RadioList and Select elements
    /// </summary>
    public class SelectItem
    {

        /// <summary>
        /// Determines if this item is selected in the options list
        /// </summary>
        public bool Selected;

        public SelectItem()
        {
        }

        /// <summary>
        /// Specify the text when creating. Will assign the text to the value and text element
        /// </summary>
        /// <param name="Text">The text to use for the option element. Assigned to the value by default as well</param>
        public SelectItem(string Text)
        {
            Value = Text;
            this.Text = Text;
        }

        /// <summary>
        /// Specify the text and value for the option tag
        /// </summary>
        /// <param name="Text">The text to use for the option element.</param>
        /// <param name="Value">The value to use for the option element.</param>
        public SelectItem(string Text, string Value)
        {
            this.Value = Value;
            this.Text = Text;
        }

        /// <summary>
        /// Specify the text and value for the option tag as well as wether it is selected
        /// </summary>
        /// <param name="Text">The text to use for the option element.</param>
        /// <param name="Value">The value to use for the option element.</param>
        /// <param name="Selected">Indictes weather the current item is selected or not</param>
        public SelectItem(string Text, string Value, bool Selected)
        {
            this.Value = Value;
            this.Text = Text;
            this.Selected = Selected;
        }

        private string _value;
        public string Value
        {
            get { return _value; }
            set { _value = value; }
        }

        private string _text;
        public string Text
        {
            get { return _text; }
            set
            {
                _text = value;
                if (string.IsNullOrEmpty(_value))
                {
                    _value = _text;
                }
            }
        }

    }
}
